<%@ WebHandler Language="C#" Class="TicketHandler" %>

using System;
using System.Web;

/// <summary>
/// Ten HttpHandler sluzy do rozliczania karnetu, tzn. odejmowania z jego puli
/// punktow za usluge, wobec ktorej ma nastapic rozliczenie.
/// </summary>
public class TicketHandler : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        
        int ticketID = int.Parse(context.Request.QueryString["ticketID"]);
        int serviceID = int.Parse(context.Request.QueryString["serviceID"]);
        string returnUrl = context.Request.QueryString["returnUrl"];

        bool success = Delegate.AccountTicket(ticketID, serviceID);

        if (success)
            context.Response.Redirect(returnUrl + "?success=true");
        else
            context.Response.Redirect(returnUrl + "?success=false");
        
    }

    
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}